<%@ page contentType="text/html; charset=utf-8" %>

<%@ include file="/WEB-INF/jsp/includeCss.jsp"%>
<%@ include file="/WEB-INF/jsp/includeJs.jsp"%>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp"%>

<form id="saveForm" method="post" action="<c:url value="/admin/editProjectType.html" />">

<table width="100%" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td valign="top">
      <table class="dbborder" width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="bottom" class="blueTableBg">&nbsp;配置管理&nbsp;-&nbsp;编辑项目类型</td>
        </tr>
        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="5">
              <tr>
                <td>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="dashTopLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTop" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTopRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td align="center">
                        <table width="100%" border="0" cellpadding="0" cellspacing="3">
                          <tr>
                            <td width="114" height="20" class="globalText">项目类型名称</td>
                            <td height="20" class="globalText">
                            	<input type="text" class="txtbox required" size="20" name="categoryName" id="categoryName" value="${projectCategory.name}"/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">包含任务</td>
                            <td height="20" class="globalText">
                            	<div style="margin-left: 0px;" class="divLeft3">
                            		<dl>
                            			 <c:forEach var="job" items="${jobList}" varStatus="status">
									          <dd style="width: 250px;">
                            					<input type="checkbox" id="job_${job.id}" value="${job.id}" <c:if test="${job.removed==1}">data_removed</c:if> />
                            					<label for="job_${job.id}">${job.name}</label>
                            				  </dd>
								         </c:forEach>
                            		</dl>
                            	</div>
                            </td>
                          </tr>
                          <tr>
                            <td align="center" colspan="2">
                              <table border="0" cellpadding="0" cellspacing="2">
                                <tr>
                                  <td><input type="button" onclick="saveProjectType();" class="btnStyle" value="  保存  "></td>

                                  <td><input onclick="javascript:window.history.back();" type="button" class="btnStyle" value=" 返回  "></td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td class="dashRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashBottomLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottom" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottomRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<input type="hidden" name="jobs" id="jobs" />
<input type="hidden" name="projCatId" value="${projectCategory.id}" />
</form>


<script>
	function saveProjectType(){
		var checkbox=$("input:checked");
		if(checkbox.length<1){
			alert('未选择任务');
			return;
		}
		var jobs="";
		checkbox.each(function(){
			jobs+=this.value+";";
		});

		$("#jobs").val(jobs);
		$("#saveForm").submit();
	}

	$(document).ready(function(){
        var rd = [], sd;
		<c:forEach var="job" items="${projectCategory.jobs}" varStatus="status">
            sd = $("#job_"+${job.id});
            sd.attr("checked",true);
            rd.push(sd);
		</c:forEach>
        $('dd > input[data_removed]').each(function(index, obj) {
            obj.checked || $(obj).parent('dd').remove();
        });
	});

</script>


<script>
$().ready(function() {
		var validate=$("#saveForm").validate({
			showErrors: customShowErrors,
			onfocusout:false,
			onkeyup:false,
			onclick:false
		});
	});
</script>
